<%@tag pageEncoding="UTF-8"%>
<%@ attribute name="page" type="org.springframework.data.domain.Page" required="true"%>
<%@ attribute name="paginationSize" type="java.lang.Integer" required="true"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
    int current =  page.getNumber() + 1;
    int begin = Math.max(1, current - paginationSize/2);
    int end = Math.min(begin + (paginationSize - 1), page.getTotalPages());

    request.setAttribute("current", current);
    request.setAttribute("begin", begin);
    request.setAttribute("end", end);
%>
<div class="p_d_10 page">
    <li><a href="?page=1&${searchParams}">首页</a></li>
    <% if (page.hasPreviousPage()){%>
    <li class="thisclass"><a href="?page=${current-1}}&${searchParams}">上一页</a></li>
    <%}%>
    <c:forEach var="i" begin="${begin}" end="${end}">
        <c:choose>
            <c:when test="${i == current}">
                <li>${i}</li>
            </c:when>
            <c:otherwise>
                <li><a href="?page=${i}&${searchParams}">${i}</a></li>
            </c:otherwise>
        </c:choose>
    </c:forEach>
    <% if (page.hasNextPage()){%>
    <li><a href="?page=${current+1}&${searchParams}">下一页</a></li>
    <%}%>
    <li><a href="?page=${page.totalPages}&${searchParams}">末页</a></li>
    <li><span class="pageinfo">共 <strong><%=page.getTotalPages()%></strong>页<strong><%=page.getTotalElements()%></strong>条</span></li>

</div>

